<?php
/*
+--------------------------------------------------------------------------
|   phpBIZbiz v3.0 full version
|   ========================================
|   by taft@wjl.cn
|   http://www.phpbiz.cn
|   all rights reserved
+---------------------------------------------------------------------------
|
|   > 
|   > 最后修改日期：2005-9-9
|   > 
|
+--------------------------------------------------------------------------
*/
!function_exists('do_login') && exit('Forbidden');
$member = new ad_member;
class ad_member
{
	var $base_url;
	var $upload_dir;
	var $upload_url;
	var $righta = array( "Promote"=>"自助商业推广",
			             "Diyc"=>"自建分类",
			             "Adver"=>"发布广告",
			             "Sharelink"=>"友情链接管理",
			             "order"=>"定单系统",
						 "Bid"=>"竟价推广系统",
			           );

    function ad_member()
    {
		global $INCOME,$CONF,$ADMIN,$ADMINER;

		$this -> base_url = $CONF['admin_url']."admin.".$CONF['php_ext'];
		$this -> upload_dir = $CONF['upload_dir'];
	    $this -> upload_url = $CONF['upload_url'];

		//---------------------------------------
		// Kill globals - globals bad, Homer good.
		//---------------------------------------
		
		$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
		
		foreach ( $tmp_in as $k => $v )
		{
			unset($$k);
		}

		/*---------------------------------------*/

		switch( $INCOME['code'])
		{
			case 'add' :
			   $this -> add_form();    //预注册
			   break;
			case 'doadd' :
		       $this -> do_add();
			   break;
			case 'findseller' :
			   $this -> do_search(0);
			   break;
			case 'adfind' :               //高级搜索
			   $this -> do_search(1);
			   break;
			 case 'ranksearch':
			   $this -> do_rank_search();
               break;
			case 'chargeseller':
			   $this -> charge_seller();
			   break;
			case 'docharge':
				$this -> do_charge();
				break;
			case 'doform' :
			   $this -> do_form(0);     //编辑细节
			   break;
			case 'modform':
			   $this -> do_form(1);
			   break;                 //修改细节
			case 'banseller':
			   $this -> do_ban(0);
			   break;
			case 'doban':
			   $this -> do_ban(1);    //暂停用户
			   break;
			case 'unbanseller':
				$this -> unban_seller();
			   break;
			case 'del':
			   $this ->del_form();
			   break;
			case 'delsearch':
			   $this -> del_search_form();
			   break;
			case 'dodel':
			   $this -> do_del();
			   break;
			case 'check':
			   $this -> check_form();
			   break;
			 case 'list':
			   $this -> all_list();
			   break;
			 case 'level':                //商家等级管理
			   $this -> level_form();
			   break;
			 case 'addlevel':
			   $this -> add_level();
			   break;
			 case 'modlevel':           //修改商家等级
			   $this -> mod_level();
			   break;
			 case 'domodlevel':
			   $this -> do_mod_level();
			   break;
			 case 'dellevel':
			   $this -> del_level();
			   break;
			 case 'reputate':            //声望管理
				$this -> set_form();
				break;
			case 'dosetr':
				$this -> do_set_form();
				break;
			default :
			   $this -> search_form();
			   break;
		}
	}

	function search_form()
	{
		global $ADMIN,$SKIN,$DB;

		$ADMIN -> page_title = "查找/编辑/暂停商家";
		$ADMIN -> page_instruction ="搜索目标商家后选择相应操作。";

		//+----------------- fast form --------------
		
		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		$ADMIN->html .= $SKIN->table_head( "商家快速搜索" );
		
		$ADMIN->html .= $SKIN->form_head();

		$ADMIN->html .= $SKIN->form_input( "act","mem",'hidden');
		$ADMIN->html .= $SKIN->form_input( "code","findseller",'hidden');
									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>键入部分或全部商家名</b>" ,
												  $SKIN->form_input( "SELLER_NAME")."<input type=checkbox value=1 name='exact'> 精确匹配"
									     )      );
									     
		$ADMIN->html .= $SKIN->form_end("查找商家");
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN->html .= $SKIN->td_spacer();

		//+------------------rank form-----------------------------

		$DB -> db_query("SELECT level_id, property_name FROM biz_seller_property");
		while($r = $DB -> db_fetch_row())
		{
              $lea[] = array($r['level_id'],$r['property_name']);
		}
					
		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );
		
		$ADMIN->html .= $SKIN->table_head( "商家分类搜索" );
		
		$ADMIN->html .= $SKIN->form_head();

		$ADMIN->html .= $SKIN->form_input( "act","mem",'hidden');
		$ADMIN->html .= $SKIN->form_input( "code","ranksearch",'hidden');
									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>选择商家等级名称</b>" ,
												 $SKIN->form_droplist("levelid",$lea))      
			                            );
									     
		$ADMIN->html .= $SKIN->form_end("查找商家");
										 
		$ADMIN->html .= $SKIN->table_end();

		$ADMIN->html .= $SKIN->td_spacer();

       //+---------------- advance form --------------
       
	   		
	   $SKIN->td_header[] = array( "&nbsp;"  , "40%" );
	   $SKIN->td_header[] = array( "&nbsp;"  , "60%" );

       $ADMIN->html .= $SKIN->table_head( "商家高级搜索","请至少填写一项，留空的项将在查询中忽略" );

	   $ADMIN->html .= $SKIN->form_head();
       $ADMIN->html .= $SKIN->form_input( "act","mem",'hidden');
       $ADMIN->html .= $SKIN->form_input( "code","adfind",'hidden');

	   									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>商家名包含</b>" ,
												  $SKIN->form_input( "seller_logaccount" )  // different from above
									     )      );
									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>Email地址包含</b>" ,
												  $SKIN->form_input( "seller_email_address" )
									     )      );
									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>所在地址包含</b>" ,
												  $SKIN->form_input( "seller_location" )
									     )      );
				                         
		$ADMIN->html .= $SKIN->table_row( array( "<b>电话号码包括</b>" ,
												  $SKIN->form_input( "seller_telephone" )
									     )      );

		$ADMIN->html .= $SKIN->table_row( array( "<b>OICQ号码包含</b>" ,
												  $SKIN->form_input( "seller_qq_number" )
									     )      );

        $ADMIN->html .= $SKIN->form_end("查找商家");
										 
		$ADMIN->html .= $SKIN->table_end();
		
		$ADMIN->output();
	}

	function add_form()
    {
		global $ADMIN,$SKIN,$DB;

		$ADMIN -> page_title = "预注册商家";
		$ADMIN -> page_instruction = "你可以使用这个表单预注册一个商家。\n";
	    $ADMIN -> nav[] = array( 'act=mem&code=add', '商家预注册' );
        
		$level = array();
		$DB -> db_query( "SELECT * FROM biz_seller_property" );
		while($r = $DB -> db_fetch_row())
		{
			$level[] = array($r['level_id'],$r['property_name']);
		}
		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );

		$ADMIN->html .= $SKIN->table_head( "商家注册" );
		
		$ADMIN->html .= $SKIN-> form_head();
		$ADMIN->html .= $SKIN-> form_input( "act","mem",'hidden');
		$ADMIN->html .= $SKIN-> form_input( "code","doadd",'hidden');
											     
		$ADMIN->html .= $SKIN->table_row( array( "<b>商家注册名</b>" ,
												  $SKIN->form_input( "seller_logaccount","" )
									     )      );
		
		$ADMIN->html .= $SKIN->table_row( array( "<b>密码</b>" ,
												  $SKIN->form_input( "seller_password", "", 'password' )
									     )      );
									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>Email地址</b>" ,
												  $SKIN->form_input( "seller_email_address","" )
									     )      );
		$ADMIN->html .= $SKIN->table_row( array( "<b>商家等级</b>",$SKIN->form_droplist("level_id",$level,1)) );
									     

		$ADMIN->html .= $SKIN->form_end("注册商家");
	    $ADMIN->html .= $SKIN->table_end();

		$ADMIN->output();
	}
	
	function do_search( $advance )
    {
		global $DB,$ADMIN,$SKIN,$INCOME,$_LEVEL;

		if( $advance )
		{ // perform advance search
			$query_condition = array();
				
			foreach( array( 'seller_logaccount','seller_telephone','seller_email_address','seller_location','seller_qq_number' ) as $bit )
			{
				$INCOME[ $bit ] = urldecode(trim($INCOME[ $bit ]));
				
				$page_query .= '&'.$bit.'='.urlencode($INCOME[ $bit ]);
				
				if ($INCOME[ $bit ] != "")
				{
					
						$query_condition[] = 'm.'.$bit." LIKE '%".$INCOME[$bit]."%'";
				}
			}

			if (count($query_condition) < 1)
			{
				$ADMIN->error("提交搜索表单前请至少完成一项");
			}

			$rq = implode( " AND ", $query_condition );            

		}else{
		    //simple
            $INCOME['SELLER_NAME'] = trim($INCOME['SELLER_NAME']);
			if ($INCOME['SELLER_NAME'] == "")
			{
					$ADMIN->error("未输入要搜索的商家名！");
			}

			$page_query = "&SELLER_NAME=".urlencode($INCOME['SELLER_NAME']);

			if($INCOME['exact'])
				$rq = "seller_logaccount = '".$INCOME['SELLER_NAME']."'";
			else
				$rq = "seller_logaccount LIKE '%".$INCOME['SELLER_NAME']."%'";
		}

		
		$start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;
		
		$query = "SELECT m.seller_id, m.seller_email_address, m.seller_logaccount, m.seller_ip,m.seller_telephone ,m.seller_ban_status,bd.property_id,bd.end_time ,bd.money
		          FROM biz_seller m,biz_seller_data bd
		          WHERE $rq AND bd.seller_id = m.seller_id ORDER BY m.seller_logaccount LIMIT $start,10";

		$DB->db_query("SELECT COUNT(m.seller_id) as count FROM biz_seller m WHERE $rq");

		$row_count = $DB -> db_fetch_row();

		if ($row_count['count'] < 1)
				$ADMIN->error("你的搜索查询没有从用户数据库中返回任何匹配。请返回并重试");
  		
		$ADMIN->page_title = "本次商家搜索结果";
		$ADMIN->page_detail = "搜索结果。";

		$pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['count'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mem"."&code={$INCOME['code']}".$page_query
											   )
											);
		$SKIN->td_header[] = array( "IP地址"  , "15%" );
		$SKIN->td_header[] = array( "等 级"  , "10%" );
		$SKIN->td_header[] = array("过期时间","13%");
		$SKIN->td_header[] = array( "电话号码" , "10%" );
		$SKIN->td_header[] = array( "Email"   , "15%" );
		$SKIN->td_header[] = array( "点 数","5%");
		$SKIN->td_header[] = array( "编辑"    , "10%" );
		$SKIN->td_header[] = array( "冲值"    , "10%" );
		$SKIN->td_header[] = array( "暂停"    , "" );
	
	    $ADMIN->html .= $SKIN->table_head( "{$row_count['count']} "."条结果" );

		$DB->db_query($query);
		
		while ( $r = $DB->db_fetch_row() )
		{
			$pid = $r['property_id'];
			$tm = $r['end_time']?date("Y-m-d H:i",$r['end_time']):'-';
			$ban_str = ($r['seller_ban_status']=='on')? "<center><a href='{$this->base_url}?act=mem&code=unbanseller&SELLER_ID={$r['seller_id']}' title='Suspend Member'>解禁帐号</a></center>": "<center><a href='{$this->base_url}?act=mem&code=banseller&SELLER_ID={$r['seller_id']}' title='Suspend Member'>禁止帐号</a></center>";
			$ADMIN->html .= $SKIN->td_basic( "<img src='{$SKIN -> img_url}/item.gif' border='0' alt='-'>&nbsp;{$r['seller_logaccount']} ", "left", "pformstrip" );
			$ADMIN->html .= $SKIN->table_row( array( "{$r['seller_ip']}",
													 $_LEVEL[$pid][0],
													  $tm,
													  $r['seller_telephone'],
													  "<center>".$r['seller_email_address']."</center>",
													  $r['money'],
													  "<center><strong><a href='{$this->base_url}?act=mem&code=doform&SELLER_ID={$r['seller_id']}' title='Edit this seller's account'>编辑细节</a></strong></center>",
													  "<center><a href='{$this->base_url}?act=mem&code=chargeseller&SELLER_ID={$r['seller_id']}' title='charge Member'>帐号冲值</a></center>",
													  $ban_str
									     	 )      );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN->output();
	}

	function do_rank_search()
	{
		global $DB,$INCOME,$ADMIN,$SKIN;

		$lid = intval($INCOME['levelid']);
		if(!$lid) $ADMIN ->error("数据库没有返回任何匹配");

		//page
		$start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;

		$DB->db_query("SELECT COUNT(*) as count FROM biz_seller_data  WHERE property_id =".$lid);

		$row_count = $DB -> db_fetch_row();

		if ($row_count['count'] < 1)
				$ADMIN->error("你的搜索查询没有从用户数据库中返回任何匹配。请返回并重试");
		$pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['count'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mem"."&code={$INCOME['code']}&levelid={$lid}"
											   )
											);
  		
		$ADMIN->page_title = "本次商家搜索结果";
		$ADMIN->page_detail = "搜索结果。";


		$query = "SELECT  bs.*,bsd.end_time,bsd.money FROM biz_seller as bs LEFT JOIN biz_seller_data as bsd ON bs.seller_id = bsd.seller_id WHERE bsd.property_id =".$lid." LIMIT $start,10";
		
		
		$SKIN->td_header[] = array( "IP地址"  , "15%" );
		$SKIN->td_header[] = array( "可用点数","10%");
		$SKIN->td_header[] = array( "电话号码" , "10%" );
		$SKIN->td_header[] = array( "到期时间"   , "15%" );
		$SKIN->td_header[] = array( "编辑"    , "15%" );
		$SKIN->td_header[] = array( "冲值"    , "15%" );
		$SKIN->td_header[] = array( "暂停"    , "15%" );
	
	    $ADMIN->html .= $SKIN->table_head( "{$row_count['count']} "."条结果" );
		
		$DB -> db_query($query);

		while ( $r = $DB->db_fetch_row() )
		{
			
			$tm = $r['end_time']?date("Y-m-d H:i",$r['end_time']):'-';
			$ADMIN->html .= $SKIN->td_basic( "<img src='{$SKIN -> img_url}/item.gif' border='0' alt='-'>&nbsp;{$r['seller_logaccount']} ", "left", "pformstrip" );
			$ADMIN->html .= $SKIN->table_row( array( "{$r['seller_ip']}",
													 "{$r['money']}",
													  $r['seller_telephone'],
													  "<center>".$tm."</center>",
													  "<center><strong><a href='{$this->base_url}?act=mem&code=doform&SELLER_ID={$r['seller_id']}' title='Edit this seller's account'>编辑细节</a></strong></center>",
													  "<center><a href='{$this->base_url}?act=mem&code=chargeseller&SELLER_ID={$r['seller_id']}' title='charge Member'>帐号冲值</a></span></center>",
													  "<center><a href='{$this->base_url}?act=mem&code=banseller&SELLER_ID={$r['seller_id']}' title='Suspend Member'>禁止帐号</a></span></center>"
									     	 )      );
		}
		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
        $ADMIN->html .= $SKIN->table_end();
		$ADMIN->output();
	}

	function do_add()
	{
		global $INCOME, $DB, $SKIN, $ADMIN;
		
		foreach( array('seller_logaccount', 'seller_password', 'seller_email_address' ) as $field )
		{
			if ($INCOME[ $field ] == "")
			{
				$ADMIN->error("你必须填写表单中的所有项目！");
			}
		}

		$DB-> db_query("SELECT seller_id FROM biz_seller WHERE seller_logaccount = '{$INCOME[seller_logaccount]}'");
		
		if ( $DB->db_fetch_row() )
		{
			$ADMIN->error("这个用户名的商家已存在，请选择另一个");
		}

		$db_string = $DB-> db_compile_fields( array ( 'seller_logaccount' => $INCOME[seller_logaccount],
			                                          'seller_password' =>  md5($INCOME[seller_password]),
													  'seller_email_address' => $INCOME[seller_email_address]
		                                             )
											);
        $DB->db_query("INSERT INTO biz_seller (" .$db_string['fields']. ") VALUES (". $db_string['value'] .")" );
		$user_id = $DB -> db_insert_id();
		$DB->db_query("SELECT att_pic_total FROM biz_seller_property WHERE level_id =".$INCOME[level_id]);
		$rs=$DB->db_fetch_row();
		$DB -> db_query("INSERT INTO biz_seller_data (seller_id,property_id,pic_allow) VALUES ($user_id,{$INCOME[level_id]},{$rs[att_pic_total]})");
		$ADMIN->record_log("创建新商家帐户‘{$INCOME['seller_logaccount']}’");
        $ADMIN->done_screen("商家帐户已创建", "用户控制", "act=mem&code=edit" );

	}

	function do_form( $edit )
	{
		global $ADMIN,$INCOME,$DB,$SKIN;

		$id = intval( $INCOME[SELLER_ID] );

		if( $edit )
		{   //if submitted!
			$db_string = $DB-> db_compile_update_fields ( array(  "seller_logaccount"      => $INCOME[seller_logaccount] ,
				                                          "seller_location"  => $INCOME[seller_location],
				                                          "seller_telephone" => $INCOME[seller_telephone],
				                                          "seller_qq_number" => $INCOME[seller_qq_number],
				                                          "seller_ban_status" => $INCOME[seller_ban_status] =='on'? 'on':'off',
				                                          "seller_check_status" => $INCOME[seller_check_status] =='on'? 'checked':'uncheck',
														  "seller_email_address" => $INCOME[seller_email_address],
				                                          "seller_credit_rate" => $INCOME[seller_credit_rate]
				                                 )); 
			$db_query = "UPDATE biz_seller SET $db_string WHERE seller_id='".$id."'";

			$DB -> db_query($db_query);

			$DB -> db_query( " select seller_logaccount as a from biz_seller WHERE seller_id= '$id' " );
			$account = $DB -> db_fetch_row();
             
			$ADMIN->record_log("修改商家信息‘{$account[a]}’");
	        $ADMIN->done_screen("商家信息已修改", "用户控制", "act=mem&code=edit" );
		   
		}
		
		$sql = " select m.* from biz_seller m WHERE m.seller_id = '$id' LIMIT 0,1";

		$DB -> db_query( $sql );
		$seller_detail = $DB -> db_fetch_row();

		$DB -> db_query( " select count(*) as num from biz_shop where seller_id = '$id' ");
		$seller_shop = $DB -> db_fetch_row();

		$ADMIN ->page_title = "本次商家搜索结果";
		$ADMIN ->page_instruction ="修改商家信息";

		$SKIN -> td_header[] = array(" ","30%");
		$SKIN -> td_header[] = array(" ","");

		$ADMIN -> html .= $SKIN -> table_head(" ");
        $ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input( "act","mem","hidden");
        $ADMIN -> html .= $SKIN -> form_input( "code","modform","hidden" );
		$ADMIN -> html .= $SKIN -> form_input( "SELLER","{$id}","hidden");

		$ADMIN -> html .= $SKIN -> table_row( array( "商家名称", $SKIN -> form_input( "seller_logaccount","{$seller_detail[seller_logaccount]}" )));
		$ADMIN -> html .= $SKIN -> table_row( array( "此商家所开商铺数目", $seller_shop[num] ));
		$ADMIN -> html .= $SKIN -> table_row( array( "此商家登陆次数", $seller_detail[seller_log_count] ));
		$ADMIN -> html .= $SKIN -> table_row( array( "此商家上次访问", $seller_detail[seller_ip] ));

		$ADMIN -> html .= $SKIN -> table_row( array( "商家地址", $SKIN -> form_input( "seller_location","{$seller_detail[seller_location]}" )));
		$ADMIN -> html .= $SKIN -> table_row( array( "商家身份证号码", $SKIN -> form_input( "seller_idcard_number","{$seller_detail[seller_idcard_number]}" )));
		$ADMIN -> html .= $SKIN -> table_row( array( "商家联系电话", $SKIN -> form_input( "seller_telephone","{$seller_detail[seller_telephone]}" )));
		$ADMIN -> html .= $SKIN -> table_row( array( "商家Email", $SKIN -> form_input( "seller_email_address","{$seller_detail[seller_email_address]}" )));
		$ADMIN -> html .= $SKIN -> table_row( array( "商家QQ", $SKIN -> form_input( "seller_qq_number","{$seller_detail[seller_qq_number]}" )));
		$ADMIN -> html .= $SKIN -> table_row( array( "商家信誉度", $SKIN -> form_input( "seller_credit_rate","{$seller_detail[seller_credit_rate]}" )));

       
		$ban_stat = ( $seller_detail[seller_ban_status] == 'on' ) ? 'checked' : '';
		$ADMIN -> html .= $SKIN -> table_row( array( "商家是否审禁止（打勾表示禁止）", "<input type='checkbox' name='seller_ban_status' $ban_stat>"));
		$check_stat = ( $seller_detail[seller_check_status] == 'checked' ) ? 'checked' : '';
		$ADMIN -> html .= $SKIN -> table_row( array( "商家是否审通过审查（打勾表示通过）", "<input type='checkbox' name='seller_check_status' $check_stat>"));

		$ADMIN -> html .= $SKIN -> form_end( "修改提交" );
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> output();


	}

	function do_ban( $do_flag )
	{
		global $ADMIN, $SKIN, $DB, $INCOME;
		
		$id = intval( $INCOME[SELLER_ID] );
		
		$DB -> db_query( "SELECT seller_logaccount as a FROM biz_seller WHERE seller_id = '$id' " );
        $account = $DB -> db_fetch_row();

		if( $do_flag )
		{
			$DB -> db_query( "UPDATE biz_seller SET seller_ban_status = 'on' WHERE seller_id ='$id' " );
			$ADMIN->record_log("禁止了商家‘{$account[a]}’");
	        $ADMIN->done_screen("商家信息已修改", "用户控制", "act=mem&code=edit" );
           
		}else{

        $ADMIN ->page_title = "禁止商家";
		$ADMIN ->page_instruction ="如果商家不遵守基本规定，可以禁止其登陆";
		$ADMIN -> td_header[] = array("","40%");
		$ADMIN -> td_header[] = array("","60%");

		$ADMIN -> html .= $SKIN -> table_head("商家帐号禁止","注意：您可以在商家编辑里面解除禁止");

		$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= $SKIN -> form_input( "act","mem","hidden");
		$ADMIN -> html .= $SKIN -> form_input( "code","doban","hidden");
		$ADMIN -> html .= $SKIN -> td_basic("<center>是否禁止商家‘$account[a]’</center>");
		$ADMIN -> html .= $SKIN -> form_end( "禁止商家" );
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> output();


		}
	}

	function unban_seller()
	{
		global $ADMIN, $SKIN, $DB, $INCOME;
		
		$id = intval( $INCOME[SELLER_ID] );
		$DB -> db_query( "SELECT seller_logaccount as a FROM biz_seller WHERE seller_id = '$id' " );
        $account = $DB -> db_fetch_row();

		$DB -> db_query( "UPDATE biz_seller SET seller_ban_status = 'off' WHERE seller_id ='$id' " );
		$ADMIN->record_log("解禁了商家‘{$account[a]}’");
	    $ADMIN->done_screen("商家信息已修改", "用户控制", "act=mem&code=edit" );
	}

	function del_form()
	{
		global $ADMIN,$SKIN,$DB;

		$ADMIN->page_title = "删除商家";
		
		$ADMIN->page_instruction = "键入部分或全部的商家名。";

		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );

		
		$ADMIN->html .= $SKIN->table_head( "商家查找" );
		
        $ADMIN->html .= $SKIN->form_head();
		$ADMIN->html .= $SKIN->form_input("act","mem","hidden");
		$ADMIN->html .= $SKIN->form_input("code","delsearch","hidden");
									     
		$ADMIN->html .= $SKIN->table_row( array( "<b>键入部分或全部的商家登陆帐号名</b>" ,
												  $SKIN->form_input( "SELLER_NAME" )  //logaccount
									     )      );
									     
		$ADMIN->html .= $SKIN->form_end("查找用户帐户");
										 
		$ADMIN->html .= $SKIN->table_end();

		$ADMIN->output();
	}

	function del_search_form()
	{
		global $ADMIN, $SKIN, $INCOME,$DB;

		if( !$INCOME[SELLER_NAME] )
		{
			$ADMIN->error("你没有选择一个的商家名来查找！");
		}

		$DB->db_query("SELECT seller_id, seller_logaccount FROM biz_seller WHERE seller_logaccount LIKE '%".$INCOME['SELLER_NAME']."%'" );

		if (! $DB->db_fetch_num() )
		{
			$ADMIN->error("对不起，找不到任何匹配你键入的搜索字符串的商家");
		}

		while ( $r = $DB->db_fetch_row() )
		{
			$form_array[] = array( $r['seller_id'] , $r['seller_logaccount'] );
		}

		$ADMIN->page_title = "删除商家";
		
		$ADMIN->page_detail = "请选择要删除的商家。";

		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "60%" );

		$ADMIN ->html .= $SKIN->table_head("搜索结果","注意：一旦删除商家成功，此商家所属的店铺、商品、留言信息都将被删除，请小心操作！");
		
		$ADMIN -> html .= $SKIN->form_head();
		$ADMIN -> html .= $SKIN->form_input("act","mem","hidden");
		$ADMIN -> html .= $SKIN->form_input("code","dodel","hidden");
        
		$ADMIN->html .= $SKIN->table_row( array( "<b>从匹配的……选择</b>" ,
												  $SKIN->form_droplist( "SELLER_ID", $form_array )
									     )      );
		$ADMIN->html .= $SKIN->form_end("删除");
		$ADMIN->html .= $SKIN->table_end();
		$ADMIN-> output();
			
	}

	function do_del()
	{
	    global $ADMIN, $SKIN, $INCOME, $DB,$CONF;

		$p_cache= array();   // store pics name 

		if ($INCOME['SELLER_ID'] == "")
		{
			$ADMIN->error("无法确定商家ID");
		}

		$DB->db_query("SELECT * FROM biz_seller WHERE seller_id='".$INCOME['SELLER_ID']."'");
		$seller = $DB->db_fetch_row();
		
     	if ($seller['seller_id'] == "")
		{
			$ADMIN->error("无法确定商家ID");
		}

		/*-------------del the goods' and his shop(s)' pic message--------------*/

		$res = $DB -> db_query(" SELECT DISTINCT goods_id as g FROM biz_goods WHERE seller_id ='".$INCOME['SELLER_ID']."'");
       
		while( $goods = $DB-> db_fetch_row($res) )
		{
			$DB -> db_query( " SELECT pic_name as n,pic_id as i FROM biz_pic WHERE pic_goods_id ='".$goods[g]."'" );
			while( $p = $DB -> db_fetch_row() )
				                 if($p[i] !=1 )  { $p_cache[] = $p[n]; $p_thumb[] = $CONF[thumb_prefix].$p[n];}

	        $DB -> db_query( " DELETE FROM biz_pic WHERE pic_goods_id ='".$goods[g]."'" );
		    $DB -> db_query( " DELETE FROM biz_message WHERE message_owner_goods_id ='".$goods[g]."'" );
		}
		
		$res = $DB -> db_query(" SELECT DISTINCT shop_id as s FROM biz_shop WHERE seller_id ='".$INCOME['SELLER_ID']."'");
		while( $shop = $DB -> db_fetch_row($res) )
		{
			$DB -> db_query( " SELECT pic_name as n,pic_id as i FROM biz_pic WHERE pic_shop_id ='".$shop[s]."'" );
			while( $p = $DB -> db_fetch_row() )
				                 if($p[i] !=1 )    {$p_cache[] = $p[n]; $p_thumb[] = $CONF[thumb_prefix].$p[n];}
			$DB -> db_query("DELETE FROM biz_pic WHERE pic_shop_id ='".$shop[s]."'");
		    $DB -> db_query( " DELETE FROM biz_message WHERE message_owner_shop_id ='".$shop[s]."'" );
		}
		
        $ADMIN -> unlink_pic( $p_cache);
        $ADMIN -> unlink_pic( $p_thumb,1);
        
		/*-------------------del his shop(s) message----------------------*/

		$DB -> db_query(" DELETE FROM biz_shop WHERE seller_id ='".$INCOME['SELLER_ID']."'");
		$DB -> db_query( " DELETE FROM biz_message WHERE message_owner_seller_id ='".$INCOME['SELLER_ID']."'");

		/* -----------------del goods -------------------------*/
		$DB -> db_query(" DELETE FROM biz_goods WHERE seller_id ='".$INCOME['SELLER_ID']."'");

		/*---------- del self now ----*/

		$DB -> db_query( " DELETE FROM biz_seller WHERE seller_id ='".$INCOME['SELLER_ID']."'");
		$DB -> db_query( " DELETE FROM biz_seller_data WHERE seller_id ='".$INCOME['SELLER_ID']."'");

		$ADMIN->record_log("删除商家‘{$seller['seller_logaccount']}’");
		$ADMIN->done_screen("商家帐户及相关信息已删除", "用户控制", "act=mem&code=edit" );

	}

	function check_form()
	{
		global $ADMIN, $DB, $SKIN, $INCOME,$_LEVEL;

		$DB -> db_query( " SELECT COUNT(*) as ct FROM biz_seller WHERE seller_check_status = 'uncheck' ");

		$row_count = $DB -> db_fetch_row();

		if (  $row_count < 1 )
				$ADMIN->error("没有未审批的商家。");

		$start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;
		
		$query = " SELECT bs.*,bd.property_id FROM biz_seller as bs, biz_seller_data as bd WHERE bd.seller_id=bs.seller_id AND bs.seller_check_status = 'uncheck' LIMIT $start,10 ";

		$pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['ct'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mem"."&code={$INCOME['code']}"
											   )
											);


		$ADMIN -> page_title = "商家批准";
		$ADMIN -> page_instruction = "这里列出了最近注册但还未审批通过的商家";

		$SKIN->td_header[] = array( "IP地址"  , "15%" );
		$SKIN->td_header[] = array( "等 级"  , "15%" );
		$SKIN->td_header[] = array( "电话号码" , "10%" );
		$SKIN->td_header[] = array( "Email"   , "15%" );
		$SKIN->td_header[] = array( "查看详细"    , "16%" );
	
	    $ADMIN->html .= $SKIN->table_head( "{$row_count['ct']} "."条结果" );

		$DB->db_query($query );
		
		while ( $r = $DB->db_fetch_row() )
		{
			$pid = $r['property_id'];
			$ADMIN->html .= $SKIN->td_basic( "<img src='{$SKIN -> img_url}/item.gif' border='0' alt='-'>&nbsp;{$r['seller_logaccount']}", "left", "pformstrip" );
			$ADMIN->html .= $SKIN->table_row( array( "{$r['seller_ip']}",
													 $_LEVEL[$pid][0],
													  $r['seller_telephone'],
													  "<center>".$r['seller_email_address']."</center>",
													  "<center><strong><a href='{$this->base_url}?act=mem&code=doform&SELLER_ID={$r['seller_id']}' title='Edit this seller's account'>查看详细</a></strong></center>",
													  )      );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
										 
		$ADMIN->html .= $SKIN->table_end();
		
		$ADMIN->output();


	}
	
	function all_list()
	{
		global $SKIN,$ADMIN,$DB,$INCOME,$_LEVEL;

		$ADMIN-> page_title = "所有商家列表";

		$start = $INCOME['st'] ? intval( $INCOME['st'] ) : 0;

		$query = "SELECT bs.*,bd.property_id FROM biz_seller as bs,biz_seller_data as bd WHERE bs.seller_id=bd.seller_id ORDER BY bs.seller_id DESC LIMIT $start,10";

		$DB -> db_query("SELECT count(*) as ct FROM biz_seller ");

		$row_count = $DB -> db_fetch_row();

		$pages = $SKIN->build_pagelinks( array('TOTAL_POSS'  => $row_count['ct'],
											   'PER_PAGE'    => 10,
											   'CUR_ST_VAL'  => $start,
											   'L_SINGLE'    => "一页",
											   'L_MULTI'     => "页：",
											   'BASE_URL'    => $this->base_url."?act=mem"."&code={$INCOME['code']}".$page_query
											   )
											);

		$DB->db_query($query );
		
		$SKIN->td_header[] = array( "IP地址"  , "15%" );
		$SKIN->td_header[] = array( "等 级"  , "15%" );
		$SKIN->td_header[] = array( "电话号码" , "10%" );
		$SKIN->td_header[] = array( "Email"   , "15%" );
		$SKIN->td_header[] = array( "查看详细"    , "16%" );

		 $ADMIN->html .= $SKIN->table_head( "共有{$row_count['ct']}"."位注册商家" );

		while ( $r = $DB->db_fetch_row() )
		{
			
			$pid = $r['property_id'];
			$ADMIN->html .= $SKIN->td_basic( "<img src='{$SKIN -> img_url}/item.gif' border='0' alt='-'>&nbsp;{$r['seller_logaccount']}", "left", "pformstrip" );
			$ADMIN->html .= $SKIN->table_row( array( "{$r['seller_ip']}",
													 $_LEVEL[$pid][0],
													  $r['seller_telephone'],
													  "<center>".$r['seller_email_address']."</center>",
													  "<center><strong><a href='{$this->base_url}?act=mem&code=doform&SELLER_ID={$r['seller_id']}' title='Edit this seller's account'>查看详细</a></strong></center>",
													  )      );
		}

		$ADMIN->html .= $SKIN->td_basic($pages, 'right', 'pformstrip');
										 
		$ADMIN->html .= $SKIN->table_end();
		
		$ADMIN->output();

	}

	function level_form()
	{
		global $SKIN,$ADMIN,$DB,$INCOME;

		$ADMIN-> page_title = "商家等级管理";
		$ADMIN-> page_instruction = "这里可以添加和管理商家注册等级。所有等级会在注册页面出现。<br>'赠送金钱数'意为付费用户购买等级后赠送的启动资金。<br>'允许扩展功能设定'设定该等级用户是否享有各种前台管理功能。<br>'等级编号'即等级排序，数字大者等级越高。";

		$DB -> db_query( "SELECT * FROM biz_seller_property ORDER BY rank_id DESC" );

		$SKIN -> td_header[] = array("等级编号","5%");
		$SKIN -> td_header[] = array("等级名称","14%");
		$SKIN -> td_header[] = array("发布商品总数","8%");
		$SKIN -> td_header[] = array("开设商铺总数","8%");
		$SKIN -> td_header[] = array("商品有效天数","8%");
		$SKIN -> td_header[] = array("招铺可续次数","8%");
		$SKIN -> td_header[] = array("商品副图个数","8%");
		$SKIN -> td_header[] = array("赠送金钱数","8%");
		$SKIN -> td_header[] = array("月消费金钱数","8%");
		$SKIN -> td_header[] = array("费用说明","");
		$SKIN -> td_header[] = array(" ","");
		
		$ADMIN -> html .= $SKIN->table_head("已设等级");
		while( $res = $DB -> db_fetch_row() )
		{
			$ADMIN->html .= $SKIN->table_row( array( $res['rank_id'],$res['property_name'],$res['goods_total'],$res['shop_total'],$res['goods_valid_day'],$res['order_allow_count'],$res['att_pic_total'],$res['free_money'],$res['fee'],$res['buy_fee'],"<a href='{$this->base_url}?act=mem&code=modlevel&LEVEL_ID={$res[level_id]}'>修改</a> | <a href='{$this->base_url}?act=mem&code=dellevel&LEVEL_ID={$res[level_id]}'>删除</a>") );
		}
		$ADMIN -> html .= $SKIN->table_end();

		$ADMIN->html .= $SKIN->td_spacer();
        
		$SKIN -> td_header[] = array("","15%");
		$SKIN -> td_header[] = array("","");
		$ADMIN -> html .= $SKIN->table_head("新设等级");
		$ADMIN -> html .= $SKIN->form_head();
		$ADMIN -> html .= $SKIN->form_input("code","addlevel","hidden");

		$ADMIN-> html .= $SKIN->table_row( array("等级名称",$SKIN->form_input("property_name")) );
		$ADMIN-> html .= $SKIN->table_row( array("等级编号",$SKIN->form_input("rank_id")) );
		$ADMIN-> html .= $SKIN->table_row( array("发布商品总数",$SKIN->form_input("goods_total")) );
		$ADMIN-> html .= $SKIN->table_row( array("开设商铺总数",$SKIN->form_input("shop_total")) );
		$ADMIN-> html .= $SKIN->table_row( array("商品有效天数",$SKIN->form_input("goods_valid_day")) );
		$ADMIN-> html .= $SKIN->table_row( array("招铺可续次数",$SKIN->form_input("order_allow_count")) );
		$ADMIN-> html .= $SKIN->table_row( array("商品副图个数",$SKIN->form_input("att_pic_total")) );
		$ADMIN-> html .= $SKIN->table_row( array("赠送金钱数",$SKIN->form_input("free_money")) );
		$ADMIN-> html .= $SKIN->table_row( array("月消费金钱数",$SKIN->form_input("fee")));
		$ADMIN-> html .= $SKIN->table_row( array("费用说明",$SKIN->form_input("buy_fee")) );
		$ADMIN-> html .= $SKIN->td_basic("允许扩展功能设定", 'left', 'catrow2');

		foreach( $this -> righta as $k => $v)
		{
			$ADMIN-> html .= $SKIN->table_row( array($v,$SKIN->form_yes_no("rightdb[{$k}]",$right[$k])) );
		}

		$ADMIN -> html .= $SKIN->form_end(" 增 加 ");
		$ADMIN -> html .= $SKIN->table_end();

		$ADMIN->output();
	
	}

	function add_level()
	{
		global $ADMIN,$DB,$INCOME;

		$right = serialize($INCOME[rightdb]);
		$db_string = $DB-> db_compile_fields( array ( 'property_name' => $INCOME[property_name],
			                                          'goods_total' =>  intval($INCOME[goods_total]),
													  'shop_total' => intval($INCOME[shop_total]),
			                                          'goods_valid_day' => intval($INCOME[goods_valid_day]),
													  'order_allow_count' => intval($INCOME[order_allow_count]),
													  'att_pic_total' => intval($INCOME[att_pic_total]),
													  'free_money' => intval($INCOME[free_money]),
			                                          'fee' => intval($INCOME[fee]),
													  'buy_fee' => $INCOME[buy_fee] ,
			                                          'action' => $right,
													  'rank_id'=>$INCOME['rank_id'],
		)
											);
		$DB->db_query("INSERT INTO biz_seller_property  (" .$db_string['fields']. ") VALUES (". $db_string['value'] .")" );
        //@unlink(ROOT_PATH.'cache/level_cache.php');
		$level_cache = new cache;
		$level_cache -> cache_level();
		$ADMIN->record_log("添加商家等级‘{$INCOME['property_name']}’");
		$ADMIN->done_screen("商家等级已添加", "商家等级管理", "act=mem&code=level" );
	}

	function mod_level()
	{
		global $ADMIN,$DB,$INCOME,$SKIN;

		$id = intval($INCOME[LEVEL_ID]);

		$DB -> db_query("SELECT * FROM biz_seller_property WHERE level_id =$id LIMIT 1");
        $r = $DB -> db_fetch_row();
		$right = unserialize($r[action]);
		$ADMIN -> page_title="修改商家等级";
        
		$SKIN->td_header[] = array(" ","15%");
		$SKIN->td_header[] = array(" ","");

		$ADMIN->html .= $SKIN -> table_head();
		$ADMIN->html .= $SKIN -> form_head();
		$ADMIN->html .= $SKIN -> form_input("code","domodlevel","hidden");
		$ADMIN->html .= $SKIN -> form_input("LEVEL_ID",$id,"hidden");
	    $ADMIN-> html .= $SKIN->td_basic("基本设定", 'left', 'catrow2');
		$ADMIN-> html .= $SKIN->table_row( array("等级名称",$SKIN->form_input("property_name",$r[property_name])) );
		$ADMIN-> html .= $SKIN->table_row( array("等级编号",$SKIN->form_input("rank_id",$r[rank_id])) );
		$ADMIN-> html .= $SKIN->table_row( array("发布商品总数（件）",$SKIN->form_input("goods_total",$r[goods_total])) );
		$ADMIN-> html .= $SKIN->table_row( array("开设商铺总数（个）",$SKIN->form_input("shop_total",$r[shop_total])) );
		$ADMIN-> html .= $SKIN->table_row( array("商品有效天数（天）",$SKIN->form_input("goods_valid_day",$r[goods_valid_day])) );
		$ADMIN-> html .= $SKIN->table_row( array("招铺可续次数（次）",$SKIN->form_input("order_allow_count",$r[order_allow_count])) );
		$ADMIN-> html .= $SKIN->table_row( array("商品副图个数",$SKIN->form_input("att_pic_total",$r[att_pic_total])) );
		$ADMIN-> html .= $SKIN->table_row( array("赠送金钱数",$SKIN->form_input("free_money",$r[free_money])) );
		$ADMIN-> html .= $SKIN->table_row( array("月消费金钱数",$SKIN->form_input("fee",$r[fee])));
		$ADMIN-> html .= $SKIN->table_row( array("费用说明",$SKIN->form_input("buy_fee",$r[buy_fee])) );
		$ADMIN-> html .= $SKIN->td_basic("允许扩展功能设定", 'left', 'catrow2');

		foreach( $this -> righta as $k => $v)
		{
			$ADMIN-> html .= $SKIN->table_row( array($v,$SKIN->form_yes_no("rightdb[{$k}]",$right[$k])) );
		}
		$ADMIN->html .=$SKIN->form_end(" 修 改 ");
		$ADMIN->html .=$SKIN->table_end();
		$ADMIN->output();

	}

	function do_mod_level()
	{

		global $ADMIN,$DB,$INCOME,$SKIN;

		$right = serialize($INCOME[rightdb]);
		if( $id = $INCOME['LEVEL_ID'] )
		{

			$db_string = $DB-> db_compile_update_fields ( array(  "property_name" => $INCOME[property_name] ,
				                                          "goods_total"  => intval($INCOME[goods_total]),
				                                          "shop_total" => intval($INCOME[shop_total]),
				                                          "goods_valid_day" => intval($INCOME[goods_valid_day]),
				                                          "order_allow_count" => intval($INCOME[order_allow_count]) ,
														  "att_pic_total"=> intval($INCOME[att_pic_total]),
				                                          "free_money" => intval($INCOME[free_money]),
				                                          "fee" => intval($INCOME[fee]),
				                                          "buy_fee"=>$INCOME[buy_fee],
				                                          "action"=>$right,
														  "rank_id"=>$INCOME['rank_id'],
				                                 )); 
			$db_query = "UPDATE biz_seller_property SET $db_string WHERE level_id=".$id;

			$DB -> db_query($db_query);
		}
        //@unlink(ROOT_PATH.'cache/level_cache.php');
		$level_cache = new cache;
		$level_cache -> cache_level();

		$ADMIN->record_log("修改商家等级‘{$INCOME['property_name']}’");
		$ADMIN->done_screen("商家等级已修改", "商家等级管理", "act=mem&code=level" );

	}

	function del_level()
	{
		global $ADMIN,$DB,$INCOME,$_LEVEL;
        $leveldata=array_keys($_LEVEL);
		$id = intval($INCOME['LEVEL_ID']);
		if($leveldata[0]==$id)
			$ADMIN->error("至少保留一个基本等级");
		$DB -> db_query("UPDATE biz_seller_data SET property_id =".$leveldata[0]." WHERE property_id=".$id);
		$DB -> db_query("DELETE FROM biz_seller_property WHERE level_id=".$id);
        //@unlink(ROOT_PATH.'cache/level_cache.php');
		$level_cache = new cache;
		$level_cache -> cache_level();
		$ADMIN->record_log("删除商家等级");
		$ADMIN->done_screen("商家等级已删除", "商家等级管理", "act=mem&code=level" );
	}
	function charge_seller()
	{
		global $ADMIN,$DB,$INCOME,$SKIN;
		$id = intval($INCOME[SELLER_ID]);
		$DB -> db_query("SELECT money FROM biz_seller_data WHERE seller_id=".$id." LIMIT 1");
		$rs = $DB -> db_fetch_row();
		$ADMIN -> page_title="商家冲值";
		$ADMIN -> page_instruction="业务核心，日志记录，请小心操作！";

		$SKIN->td_header[] = array(" ","15%");
		$SKIN->td_header[] = array(" ","");
        
		$ADMIN -> html = $SKIN-> table_head();
		$ADMIN -> html .=$SKIN->form_head();
        $ADMIN -> html .=$SKIN->form_input("code","docharge","hidden");
		$ADMIN -> html .=$SKIN->form_input("ID",$id,"hidden");  //冲值家的ID
		$ADMIN -> html .=$SKIN->table_row( array("冲值金额：",$SKIN -> form_input("money")."当前用户余额".$rs['money']) );
		$ADMIN -> html .=$SKIN->form_end(" 提 交 ");
		$ADMIN -> html .=$SKIN ->table_end();
		$ADMIN -> output();
	}
	function do_charge()
	{
		global $ADMIN,$DB,$INCOME,$ADMINER;
		$id = intval($INCOME[ID]);
		$money = intval($INCOME[money]);
		$timestamp=time();
		$DB -> db_query("SELECT * FROM biz_seller WHERE seller_id=".$id." LIMIT 1");
		if( !$DB -> db_fetch_num() ) 
			$ADMIN ->error("该商家不存在，冲值失败！");
		$r = $DB -> db_fetch_row();
		$DB -> db_query("UPDATE biz_seller_data SET money = money+".$money." WHERE seller_id =".$id);
		if(! $DB -> db_affected_rows() ) 	
			$ADMIN ->error("冲值失败！");
        // write charge log
		$DB -> db_query( "INSERT INTO biz_charge_log ( `seller_logaccount` , `operator` , `time` , `money`,`sid` ) VALUES (
                    '{$r[seller_logaccount]}', '{$ADMINER[user_account]}', '{$timestamp}', '{$money}','{$id}')" );
		$DB -> db_query("SELECT money FROM biz_seller_data WHERE seller_id=".$id." LIMIT 1");
		$rs = $DB -> db_fetch_row();

		$ADMIN->record_log("给商家{$r[seller_logaccount]}冲值{$money}");
		$ADMIN->done_screen("商家已冲{$money}。当前帐户余额".$rs['money'], "商家管理", "act=mem&code=edit" );
	}

	function set_form()
	{
		global $ADMIN,$SKIN,$DB;

		$ADMIN -> page_title = "商家声望管理";
		$ADMIN -> page_instruction = "你可以在这里设定声望加分数目。";

		$DB -> db_query("SELECT * FROM biz_global_configure WHERE `key`='repute_db'"); 
		$r = $DB ->db_fetch_row();
        $redb = unserialize($r['value']);

		$SKIN -> td_header[] = array("","15%");
		$SKIN -> td_header[] = array("","");
		$ADMIN -> html .= $SKIN->table_head("加分管理");
		$ADMIN -> html .= $SKIN->form_head();
		$ADMIN -> html .= $SKIN->form_input("code","dosetr","hidden");

		$ADMIN-> html .= $SKIN->table_row( array("登陆加分",$SKIN->form_input("reputedb[login_add]",$redb['login_add'])) );
		$ADMIN-> html .= $SKIN->table_row( array("发布商品加分",$SKIN->form_input("reputedb[goods_add]",$redb['goods_add'])) );
		$ADMIN-> html .= $SKIN->table_row( array("开设商铺加分",$SKIN->form_input("reputedb[shop_add]",$redb['shop_add'])) );
		$ADMIN-> html .= $SKIN->table_row( array("推荐商铺加分",$SKIN->form_input("reputedb[idx_shop_add]",$redb['idx_shop_add'])) );
		$ADMIN-> html .= $SKIN->table_row( array("推荐商品加分",$SKIN->form_input("reputedb[idx_goods_add]",$redb['idx_goods_add'])) );

		$ADMIN -> html .= $SKIN->form_end(" 提 交 ");
		$ADMIN -> html .= $SKIN->table_end();

		$ADMIN->output();
	}
	function do_set_form()
	{
		global $ADMIN,$INCOME,$SKIN,$std;
		$cache_file= ROOT_PATH."cache/repute_cache.php";
		$reputedb = $INCOME[reputedb];
		$master['repute_db'] = serialize($reputedb);
		$std -> rebuild_config($master);
		@unlink($cache_file);
		$ADMIN ->record_log("更新声望设置");
		$ADMIN->done_screen("成功更新声望设置", "声望设定", "act=mem&code=reputate" );
	}
}

?>